using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using ALib;
using AxTWSLib;
using TWSLib;
using _DTwsEvents_historicalDataEventHandler = AxTWSLib._DTwsEvents_historicalDataEventHandler;
using _DTwsEvents_updateAccountValueEventHandler=AxTWSLib._DTwsEvents_updateAccountValueEventHandler;

namespace TradingPlatform.IB.Operations
{
    public class ManagedAccounts
    {
        private readonly AxTws _tws;

        public string _result;

        public ManagedAccounts(AxTws tws)
        {
            _tws = tws;

            _tws.managedAccounts += new AxTWSLib._DTwsEvents_managedAccountsEventHandler(_tws_managedAccounts);
            _result = string.Empty;
        }


        public void RequestManagedAccounts()
        {
            _tws.reqManagedAccts();
        }

        void _tws_managedAccounts(object sender, _DTwsEvents_managedAccountsEvent e)
        {
            _result = e.accountsList;
        }
    }
}